﻿<UserControl x:Class="DemoNYTimes.StateZipTotalsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="Auto" Height="Auto"  mc:Ignorable="d" d:DesignHeight="480" d:DesignWidth="640"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"              
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:nyt="clr-namespace:NYTimes;assembly=NYTimesSilverlightKit" 
    xmlns:nytvc="clr-namespace:NYTimes.ValueConverters;assembly=NYTimesSilverlightKit">
	<UserControl.Resources>
		<nyt:StateZipTotals x:Key="StateZipTotalsDS" d:IsDataSource="True"/>
        <nytvc:EnumConverter x:Key="EnumConverter"/>
	</UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White" DataContext="{StaticResource StateZipTotalsDS}">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="Auto"/>
    		<RowDefinition/>
    		<RowDefinition Height="Auto"/>
    	</Grid.RowDefinitions>
    	<Grid.ColumnDefinitions>
    		<ColumnDefinition Width="Auto"/>
    		<ColumnDefinition/>
            <ColumnDefinition Width="Auto"/>
    	</Grid.ColumnDefinitions>
    	<data:DataGrid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" 
            Grid.ColumnSpan="3" Grid.Row="2" 
            ItemsSource="{Binding Mode=OneWay, Path=Results}"/>
    	<RadioButton HorizontalAlignment="Left" VerticalAlignment="Center" Content="State" 
            IsChecked="{Binding ResourceType, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=States}" 
            GroupName="Location"/>
    	<RadioButton HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="1" 
            Content="Zip Code" 
            IsChecked="{Binding ResourceType, Mode=TwoWay, Converter={StaticResource EnumConverter}, ConverterParameter=Zips}" 
            GroupName="Location"/>
    	<TextBox HorizontalAlignment="Stretch" x:Name="State" VerticalAlignment="Center" 
            Grid.Column="1" Text="{Binding Mode=TwoWay, Path=State}" TextWrapping="Wrap"
            IsEnabled="{Binding ResourceType, Converter={StaticResource EnumConverter}, ConverterParameter=States}"/>
    	<TextBox HorizontalAlignment="Stretch" x:Name="Zip_Code" VerticalAlignment="Center" 
            Grid.Column="1" Grid.Row="1" Text="{Binding Mode=TwoWay, Path=ZipCode}" 
            TextWrapping="Wrap" 
            IsEnabled="{Binding ResourceType, Converter={StaticResource EnumConverter}, ConverterParameter=Zips}"/>
    	<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                   Text="{Binding Mode=OneWay, Path=Status}" TextWrapping="Wrap" 
                   x:Name="Status" Grid.Row="3"/>
    	<TextBlock HorizontalAlignment="Stretch" VerticalAlignment="Center" 
                   Text="{Binding Mode=OneWay, Path=Copyright}" TextWrapping="Wrap" 
                   x:Name="Copyright" Grid.Row="3" Grid.Column="1"/>
        <!-- This button is to trigger the two-way data binding-->
        <Button Content="Search" Grid.Column="2" Grid.RowSpan="2" />
    </Grid>
</UserControl>
